
(define-macro (def func args body)
  `(define ,func (lambda ,args ,body))    
)


(define (map-stream f s)
    (if (null? s)
    	nil
    	(cons-stream (f (car s)) (map-stream f (cdr-stream s)))))

(define (naturals n) 
  (cons-stream n (naturals (+ n 1)))
)

(define all-three-multiples

  (map-stream (lambda (x) (* x 3)) (naturals 1))
)


(define (compose-all funcs)
  (define (compose-helper funcs pre)
    (if (null? funcs)
      pre
      (if (null? (cdr funcs))
        ((car funcs) pre)
        (compose-helper (cdr funcs) ((car funcs) pre))
      )
    )
  )
  (lambda (x) (compose-helper funcs x))
)


(define (partial-sums stream)
  (define (helper pre stream)
    (if (null? stream)
      nil
      (cons-stream (+ pre (car stream)) (helper (+ pre (car stream)) (cdr-stream stream)))
    )
  )
  (helper 0 stream)
)

